<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('预约摊位管理列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="eventOrder-form">
                <div class="select-list">
                    <ul>
                        <li>
                            预约状态：<select name="orderStatus" th:with="type=${@dict.getType('sys_order_status')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

<!--        <div class="btn-group-sm" id="toolbar" eventOrder="group">-->
<!--            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:eventOrder:add">-->
<!--                <i class="fa fa-plus"></i> 新增-->
<!--            </a>-->
<!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:eventOrder:edit">-->
<!--                <i class="fa fa-edit"></i> 修改-->
<!--            </a>-->
<!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:eventOrder:remove">-->
<!--                <i class="fa fa-remove"></i> 删除-->
<!--            </a>-->
<!--        </div>-->

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:eventOrder:pass')}]];
    var removeFlag = [[${@permission.hasPermi('system:eventOrder:refuse')}]];
    var datas = [[${@dict.getType('sys_order_status')}]];
    var prefix = ctx + "system/eventOrder";


    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            sortName: "orderId",
            modalName: "预约摊位管理",
            columns: [{
                checkbox: true
            },
                {
                    field: 'orderId',
                    title: '预约摊位编号'
                },
                {
                    field: 'eventName',
                    title: '展会名单名称'
                },
                {
                    field: 'sortName',
                    title: '展会分类名称'
                },
                {
                    field: 'eventNum',
                    title: '展会摊位总编号'
                },
                {
                    field: 'userName',
                    title: '申请人'
                },
                {
                    field: 'orderRemarks',
                    title: '备注'
                },
                {
                    field: 'orderStatus',
                    title: '申请状态',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.orderStatus != 1) {
                            return actions;
                        }else {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="pass(\'' + row.orderId + '\')"><i class="fa fa-edit"></i>通过</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="refuse(\'' + row.orderId + '\')"><i class="fa fa-remove"></i>拒绝</a> ');
                            return actions.join('');
                        }
                    }
                }]
        };
        $.table.init(options);
    });

    function pass(orderId) {
        $.modal.confirm("确定通过该申请吗？", function() {
            var data = { "orderId": orderId };
            $.operate.post(prefix + "/pass", data);
        });
    }

    function refuse(orderId) {
        $.modal.confirm("确定拒绝该申请吗？", function() {
            var data = { "orderId": orderId };
            $.operate.post(prefix + "/refuse", data);
        });
    }
</script>
</body>
</html>